package com.rock.code.updatedbtime.job;

import com.rock.code.updatedbtime.services.UpdateDbTimeService;
import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.Date;


public class UpdateDbTimeJob implements Job {

    Logger logger = Logger.getLogger("schedule");

    /**
     * 修改入库时间
     *
     * @param jobExecutionContext
     * @throws JobExecutionException
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        UpdateDbTimeService updateDbTimeService = (UpdateDbTimeService) jobExecutionContext.getMergedJobDataMap().get("updateDbTimeService");

        String timeKey = (String) jobExecutionContext.getMergedJobDataMap().get("timeKey");

//        logger.info(timeKey);

        try {
            logger.info("job start time: " + new Date());
            updateDbTimeService.updateDbTime(timeKey);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}
